import React, { Component, Suspense, lazy, useState} from 'react'


const Comingsoon = lazy(() =>  import('./components/Comingsoon') )
const Nowplaying = lazy(() =>  import('./components/Nowplaying') )
// import Comingsoon from './components/Comingsoon.js';
// import Nowplaying from './components/Nowplaying.js';

export const App = () => {
    const [type, setType] = useState(1);
  
    return (
      <div>
        <button onClick={() => setType(1)}>懒加载1</button>
        <button onClick={() => setType(2)}>懒加载2</button>
        {/* 懒加载 */}
        <Suspense fallback={<div>Loading...</div>}>
          {type === 1 ? <Comingsoon /> : <Nowplaying />}
        </Suspense>
      </div>
    );
  };
  
